/*=============================================================
(c) 2012 by Juliano Efson Sales
www.mdcc.ufc.br
================================================================*/

using HPE.External;
using HPE.Base;
using System.Collections.Generic;

namespace HPE.Test {

   public class TestLinker : HashLinker {

      public void linkComponents(List<MetaInnerComponent> components) {
         MetaUnit unit;
         MetaAction action;

         foreach(MetaHashComponent component in components) {
            if(component.Name.Equals("WriteLoveComponent")) {
               component.Entity = new WriteLoveComponent();
               
               unit = new MetaUnit();
               unit.Id = component.Id*1000;
               unit.Entity = ((WriteLoveComponent) component.Entity).Unit;
               unit.Name = "Unit";
               component.AddUnit(unit);
               
               action = new MetaAction();
               action.Id = unit.Id*100;
               action.Entity = (MetaAction.DAction) ((WriterUnit) unit.Entity).Write;
               action.Name = "Write";
               unit.AddAction(action);
               
               action = new MetaAction();
               action.Id = unit.Id*200;
               action.Entity = (MetaAction.DAction) ((WriterUnit) unit.Entity).Count;
               action.Name = "Count";
               unit.AddAction(action);
            } else if(component.Name.Equals("CountComponent")) {
               component.Entity = new CountComponent();
               
               unit = new MetaUnit();
               unit.Id = component.Id*1000;
               unit.Entity = ((CountComponent) component.Entity).Unit;
               unit.Name = "Unit";
               component.AddUnit(unit);
               
               action = new MetaAction();
               action.Id = unit.Id*100;
               action.Entity = (MetaAction.DAction) ((WriterUnit) unit.Entity).Write;
               action.Name = "Write";
               unit.AddAction(action);
               
               action = new MetaAction();
               action.Id = unit.Id*200;
               action.Entity = (MetaAction.DAction) ((WriterUnit) unit.Entity).Count;
               action.Name = "Count";
               unit.AddAction(action);
            }
         }
      }
   }
}
